<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
  <link rel="stylesheet" href="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.css">
  <link rel="stylesheet" href="/lib/pace/pace-theme-minimal.min.css">
  <script src="/lib/pace/pace.min.js"></script>

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"yoursite.com","root":"/","scheme":"Pisces","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":true,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":-1,"unescape":false,"preload":true},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"./public/search.xml"};
  </script>

  <meta name="description" content="img标签介绍介绍img: 英文全称 image（图像），代表的是一张图片。 如果要想在网页中显示图像，就可以使用img 标签，它是一个单标签。语法如下： 1&lt;img src&#x3D;&quot;图片的URL&quot; &#x2F;&gt;">
<meta property="og:type" content="article">
<meta property="og:title" content="06-HTML标签：图片标签">
<meta property="og:url" content="http://yoursite.com/2020/07/07/06-HTML%E6%A0%87%E7%AD%BE%EF%BC%9A%E5%9B%BE%E7%89%87%E6%A0%87%E7%AD%BE/index.html">
<meta property="og:site_name" content="GipBaby270&#39;s Blog">
<meta property="og:description" content="img标签介绍介绍img: 英文全称 image（图像），代表的是一张图片。 如果要想在网页中显示图像，就可以使用img 标签，它是一个单标签。语法如下： 1&lt;img src&#x3D;&quot;图片的URL&quot; &#x2F;&gt;">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://img.smyhvae.com/20151001_19.jpg">
<meta property="og:image" content="http://img.smyhvae.com/20170630_1133.png">
<meta property="og:image" content="http://img.smyhvae.com/2015-10-01-cnblogs_html_21.png">
<meta property="og:image" content="http://img.smyhvae.com/2015-10-01-cnblogs_html_20.png">
<meta property="og:image" content="http://img.smyhvae.com/2015-10-02-cnblogs_html_19.png">
<meta property="og:image" content="http://img.smyhvae.com/2015-10-02-cnblogs_html_21.png">
<meta property="og:image" content="http://img.smyhvae.com/2015-10-02-cnblogs_html_22.png">
<meta property="og:image" content="http://img.smyhvae.com/2015-10-02-cnblogs_html_23.png">
<meta property="og:image" content="http://img.smyhvae.com/2015-10-02-cnblogs_html_24.png">
<meta property="article:published_time" content="2020-07-07T10:24:42.740Z">
<meta property="article:modified_time" content="2020-07-07T11:16:24.131Z">
<meta property="article:author" content="Gip886">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://img.smyhvae.com/20151001_19.jpg">

<link rel="canonical" href="http://yoursite.com/2020/07/07/06-HTML%E6%A0%87%E7%AD%BE%EF%BC%9A%E5%9B%BE%E7%89%87%E6%A0%87%E7%AD%BE/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>06-HTML标签：图片标签 | GipBaby270's Blog</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    
    <a href="https://github.com/Gip886" target="_blank" rel="noopener" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#64CEAA; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
    
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">GipBaby270's Blog</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Fighting for BAT!</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2020/07/07/06-HTML%E6%A0%87%E7%AD%BE%EF%BC%9A%E5%9B%BE%E7%89%87%E6%A0%87%E7%AD%BE/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/%E5%A4%B4%E5%83%8F.jpg">
      <meta itemprop="name" content="Gip886">
      <meta itemprop="description" content="为了更美好的明天而战">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="GipBaby270's Blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          06-HTML标签：图片标签
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2020-07-07 18:24:42 / 修改时间：19:16:24" itemprop="dateCreated datePublished" datetime="2020-07-07T18:24:42+08:00">2020-07-07</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/HTML%E5%9F%BA%E7%A1%80/" itemprop="url" rel="index"><span itemprop="name">HTML基础</span></a>
                </span>
            </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span><br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>2.6k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>2 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h2 id="img标签介绍"><a href="#img标签介绍" class="headerlink" title="img标签介绍"></a>img标签介绍</h2><h3 id="介绍"><a href="#介绍" class="headerlink" title="介绍"></a>介绍</h3><p>img: 英文全称 image（图像），代表的是一张图片。</p>
<p>如果要想在网页中显示图像，就可以使用img 标签，它是一个单标签。语法如下：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">"图片的URL"</span> /&gt;</span></span><br></pre></td></tr></table></figure>

<a id="more"></a>

<h3 id="能插入的图片类型"><a href="#能插入的图片类型" class="headerlink" title="能插入的图片类型"></a>能插入的图片类型</h3><ul>
<li><p>能够插入的图片类型是：jpg(jpeg)、gif、png、bmp等。</p>
</li>
<li><p>不能往网页中插入的图片格式是：psd、ai等。</p>
</li>
</ul>
<p>HTML页面不是直接插入图片，而是插入图片的引用地址，所以要先把图片上传到服务器上。</p>
<h2 id="img标签的src属性"><a href="#img标签的src属性" class="headerlink" title="img标签的src属性"></a>img标签的<code>src</code>属性</h2><p>这里涉及到图片的一个属性：</p>
<ul>
<li><code>src</code>属性：指图片的路径。英文名称 source。</li>
</ul>
<p>在写<strong>图片的路径</strong>时，有两种写法：相对路径、绝对路径</p>
<h3 id="写法一：图片的相对路径"><a href="#写法一：图片的相对路径" class="headerlink" title="写法一：图片的相对路径"></a>写法一：图片的相对路径</h3><p>相对当前页面所在的路径。两个标记 <code>.</code> 和 <code>..</code> 分表代表当前目录和上一层目录。</p>
<p>举例1：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!-- 当前目录中的图片 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">"2.jpg"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">".\2.jpg"</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="comment">&lt;!-- 上一级目录中的图片 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">"..\2.jpg"</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>相对路径不会出现这种情况：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">aaa/../bbb/1.jpg</span><br></pre></td></tr></table></figure>

<p><code>../</code>要么不写，要么就写在开头。</p>
<p>举例2：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">"images/1.jpg"</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p>上方代码的意思是说，当前html页面有一个并列的文件夹<code>images</code>，在文件夹<code>images</code>中存放了一张图片<code>1.jpg</code><br>效果：</p>
<p><img src="http://img.smyhvae.com/20151001_19.jpg" alt="Paste_Image.png"></p>
<p>相对路径的面试题。现有如下文件层级图：</p>
<p><img src="http://img.smyhvae.com/20170630_1133.png" alt></p>
<p>问题：如果想在index.html中插入1.png，那么对应的img语句是？</p>
<p>分析：</p>
<p>现在document是最大的文件夹，里面有两个文件夹work和photo。work中又有一个文件夹叫做myweb。myweb文件夹里面有index.html。  所以index.html在myweb文件夹里面，上一级就是work文件夹，上两级就是document文件夹。通过document文件夹当做一个中转站，进入photo文件夹，看到了1.png。</p>
<p>答案：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">"../../photo/1.png"</span> /&gt;</span></span><br></pre></td></tr></table></figure>

<h3 id="写法二：图片的绝对路径"><a href="#写法二：图片的绝对路径" class="headerlink" title="写法二：图片的绝对路径"></a>写法二：图片的绝对路径</h3><p>绝对路径包括以下两种：</p>
<p>（1）以盘符开始的绝对路径。举例：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">"C:\Users\qianguyihao\Desktop\html\images\1.jpg"</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>（2）网络路径。举例：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">"http://img.smyhvae.com/20200122_200901.png"</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>大家打开上面的img中的链接，可能有惊喜哦。</p>
<h3 id="相对路径和绝对路径的总结"><a href="#相对路径和绝对路径的总结" class="headerlink" title="相对路径和绝对路径的总结"></a>相对路径和绝对路径的总结</h3><p>相对路径的好处：站点不管拷贝到哪里，文件和图片的相对路径关系都是不变的。相对路径使用有一个前提，就是网页文件和你的图片，必须在一个服务器上。</p>
<p>问题：我的网页在C盘，图片却在D盘，能不能插入呢？</p>
<p>答案： 用相对路径不能，用绝对路径也不能。</p>
<p>注意：可以使用file://来插入，但是这种方法，没有任何意义！因为服务器上没有所谓c盘、d盘。</p>
<p>下面的方法是行的，但是没有任何工程上的意义，这是因为服务器没有盘符，linux系统没有盘符：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">"file://C:\Users\qianguyihao\Pictures\明星\1.jpg"</span> <span class="attr">alt</span>=<span class="string">""</span> /&gt;</span></span><br></pre></td></tr></table></figure>

<p><strong>总结一下</strong>：</p>
<p>无论是在 a 标签还是 img 标签上，如果要用路径。只有两种路径能用，就是相对路径和绝对路径：</p>
<ul>
<li><p>相对路径从自己出发，找到别人。</p>
</li>
<li><p>绝对路径，就是<code>http://</code>或者<code>https://</code>开头的路径。</p>
</li>
<li><p>绝对不允许使用<code>file://</code>开头的文件，这个是完全错误的！</p>
</li>
</ul>
<h2 id="img标签的其他属性"><a href="#img标签的其他属性" class="headerlink" title="img标签的其他属性"></a>img标签的其他属性</h2><h3 id="width、height-属性"><a href="#width、height-属性" class="headerlink" title="width、height 属性"></a>width、height 属性</h3><ul>
<li><p><code>width</code>：图像的宽度。</p>
</li>
<li><p><code>height</code>：图像的高度。</p>
</li>
</ul>
<p>width和height，在 HTML5 中的单位是 CSS 像素，在 HTML 4 中既可以是像素，也可以是百分比。可以只指定 width 和 height 中的一个值，浏览器会根据原始图像进行缩放。</p>
<p><strong>重要提示</strong>：如果要想保证图片等比例缩放，请只设置width和height中其中一个。</p>
<h3 id="Alt-属性"><a href="#Alt-属性" class="headerlink" title="Alt 属性"></a>Alt 属性</h3><ul>
<li><code>alt</code>：当图片不可用（无法显示）的时候，代替图片显示的内容。alt是英语 alternate “替代”的意思，代表替换资源。</li>
</ul>
<p><code>Alt</code>属性效果演示：</p>
<p><img src="http://img.smyhvae.com/2015-10-01-cnblogs_html_21.png" alt="Paste_Image.png"></p>
<p>如上图所示：当图片 src 不可用的时候，显示文字。这样做，至少能让用户知道，这个图片大概是什么内容。</p>
<h3 id="title-属性"><a href="#title-属性" class="headerlink" title="title 属性"></a>title 属性</h3><ul>
<li><code>title</code>：<strong>提示性文本</strong>。鼠标悬停时出现的文本。</li>
</ul>
<p>title 属性不该被用作一幅图片在 alt 之外的补充说明信息。如果一幅图片需要小标题，使用 figure 或 figcaption 元素。</p>
<p>title 元素的值一般作为提示条(tooltip)呈现给用户，在光标于图片上停下后显示出来。尽管这确实能给用户提供更多的信息，您不该假定用户真的能看到：用户可能只有键盘或触摸屏。如果要把特别重要的信息提供给用户，可以选择上面提供的一种方法将其内联显示，而不是使用 title。</p>
<p>举例：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">img</span> <span class="attr">src</span>=<span class="string">"images/1.jpg"</span> <span class="attr">width</span>=<span class="string">"300"</span> <span class="attr">height</span>=<span class="string">"`188"</span> <span class="attr">title</span>=<span class="string">"这是美女"</span>&gt;</span></span><br></pre></td></tr></table></figure>

<p>效果：</p>
<p><img src="http://img.smyhvae.com/2015-10-01-cnblogs_html_20.png" alt="Paste_Image.png"></p>
<h3 id="align-属性"><a href="#align-属性" class="headerlink" title="align 属性"></a>align 属性</h3><ul>
<li>图片的<code>align</code>属性：<strong>图片和周围文字的相对位置</strong>。属性取值可以是：bottom（默认）、center、top、left、right。</li>
</ul>
<p>如果想实现图文混排的效果，请使用align属性，取值为left或right。</p>
<p>我们来分别看一下这<code>align</code>属性的这几个属性值的区别。</p>
<p>1、<code>align=&quot;&quot;</code>，图片和文字低端对齐。即默认情况下的显示效果：</p>
<p><img src="http://img.smyhvae.com/2015-10-02-cnblogs_html_19.png" alt></p>
<p>2、<code>align=&quot;center&quot;</code>：图片和文字水平方向上居中对齐。显示效果：</p>
<p><img src="http://img.smyhvae.com/2015-10-02-cnblogs_html_21.png" alt></p>
<p>3、<code>align=&quot;top&quot;</code>：图片与文字顶端对齐。显示效果：</p>
<p><img src="http://img.smyhvae.com/2015-10-02-cnblogs_html_22.png" alt></p>
<p>4、<code>align=&quot;left&quot;</code>：图片在文字的左边。显示效果：</p>
<p><img src="http://img.smyhvae.com/2015-10-02-cnblogs_html_23.png" alt></p>
<p>5、<code>align=&quot;right&quot;</code>：图片在文字的右边。显示效果：</p>
<p><img src="http://img.smyhvae.com/2015-10-02-cnblogs_html_24.png" alt></p>
<h3 id="其他已废弃的属性"><a href="#其他已废弃的属性" class="headerlink" title="其他已废弃的属性"></a>其他已废弃的属性</h3><ul>
<li><code>Align</code>（已废弃）：指图片的水平对齐方式，属性值可以是：top、middle、bottom、left、center、right。该属性已废弃，替换为 <code>vertical-align</code>这个CSS属性。</li>
<li><code>border</code>（已废弃）：给图片加边框，单位是像素，边框的颜色默认黑色。该属性已废弃，替换为 <code>border</code>这个CSS属性。</li>
<li><code>Hspace</code>（已废弃）：指图片左右的边距。</li>
<li><code>Vspace</code>（已废弃）：指图片上下的边距。</li>
</ul>

    </div>

    
    
    
        <div class="reward-container">
  <div>坚持原创技术分享，您的支持将鼓励我继续分享！</div>
  <button onclick="var qr = document.getElementById('qr'); qr.style.display = (qr.style.display === 'none') ? 'block' : 'none';">
    打赏
  </button>
  <div id="qr" style="display: none;">
      
      <div style="display: inline-block;">
        <img src="/images/wechatpay.png" alt="Gip886 微信支付">
        <p>微信支付</p>
      </div>

  </div>
</div>


      <footer class="post-footer">

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2020/07/07/05-HTML%E6%A0%87%E7%AD%BE%EF%BC%9A%E5%AD%97%E4%BD%93%E6%A0%87%E7%AD%BE%E5%92%8C%E8%B6%85%E9%93%BE%E6%8E%A5/" rel="prev" title="05-HTML标签：字体标签和超链接">
      <i class="fa fa-chevron-left"></i> 05-HTML标签：字体标签和超链接
    </a></div>
      <div class="post-nav-item">
    <a href="/2020/07/07/01-JS%E7%AE%80%E4%BB%8B/" rel="next" title="01-JS简介">
      01-JS简介 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#img标签介绍"><span class="nav-number">1.</span> <span class="nav-text">img标签介绍</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#介绍"><span class="nav-number">1.1.</span> <span class="nav-text">介绍</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#能插入的图片类型"><span class="nav-number">1.2.</span> <span class="nav-text">能插入的图片类型</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#img标签的src属性"><span class="nav-number">2.</span> <span class="nav-text">img标签的src属性</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#写法一：图片的相对路径"><span class="nav-number">2.1.</span> <span class="nav-text">写法一：图片的相对路径</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#写法二：图片的绝对路径"><span class="nav-number">2.2.</span> <span class="nav-text">写法二：图片的绝对路径</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#相对路径和绝对路径的总结"><span class="nav-number">2.3.</span> <span class="nav-text">相对路径和绝对路径的总结</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#img标签的其他属性"><span class="nav-number">3.</span> <span class="nav-text">img标签的其他属性</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#width、height-属性"><span class="nav-number">3.1.</span> <span class="nav-text">width、height 属性</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Alt-属性"><span class="nav-number">3.2.</span> <span class="nav-text">Alt 属性</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#title-属性"><span class="nav-number">3.3.</span> <span class="nav-text">title 属性</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#align-属性"><span class="nav-number">3.4.</span> <span class="nav-text">align 属性</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#其他已废弃的属性"><span class="nav-number">3.5.</span> <span class="nav-text">其他已废弃的属性</span></a></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="Gip886"
      src="/images/%E5%A4%B4%E5%83%8F.jpg">
  <p class="site-author-name" itemprop="name">Gip886</p>
  <div class="site-description" itemprop="description">为了更美好的明天而战</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">29</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">7</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/Gip886" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;Gip886" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>



      </div>
        <iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=300 height=86 src="//music.163.com/outchain/player?type=2&id=492390949&auto=1&height=66"></iframe>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Gip886</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-area"></i>
    </span>
      <span class="post-meta-item-text">站点总字数：</span>
    <span title="站点总字数">153k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span class="post-meta-item-text">站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">2:19</span>
</div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script size="300" alpha="0.6" zIndex="-1" src="/lib/canvas-ribbon/canvas-ribbon.js"></script>
  <script src="/lib/anime.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js"></script>
  <script src="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>


  <script defer src="/lib/three/three.min.js"></script>
    <script defer src="/lib/three/canvas_lines.min.js"></script>


  




  
<script src="/js/local-search.js"></script>













  

  

<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","model":{"jsonPath":"/live2dw/assets/koharu.model.json"},"display":{"position":"right","width":150,"height":300},"mobile":{"show":true},"log":false,"tagMode":false});</script></body>
<!-- 页面点击小红心 -->
<script type="text/javascript" src="/js/clicklove.js"></script>
</html>

